home *** CD-ROM | disk | FTP | other *** search
- { ginput2.pas -- Get input via TInputDialog (modified version) }
-
- program Ginput;
-
- {$R ginput.res}
-
- uses WinTypes, WinProcs, WObjects, StdDlgs;
-
- const
-
- id_Menu = 100; { Menu resource ID }
- cm_Prompt = 101; { Prompt command ID }
-
- type
-
- PCustom = ^TCustom;
- TCustom = object(TInputDialog)
- function CanClose: Boolean; virtual;
- end;
-
- GinputApplication = object(TApplication)
- procedure InitMainWindow; virtual;
- end;
-
- PGinputWindow = ^GinputWindow;
- GinputWindow = object(TWindow)
- Buffer: array[0 .. 64] of Char;
- constructor Init(AParent: PWindowsObject; ATitle: PChar);
- procedure GetInput(var Msg: TMessage);
- virtual cm_First + cm_Prompt;
- end;
-
-
- { TCustom }
-
- function TCustom.CanClose: Boolean;
- var
- OkToClose: Boolean;
- begin
- OkToClose := TInputDialog.CanClose;
- if OkToClose then
- OkToClose := Upcase(Buffer[0]) = 'Y';
- if not OkToClose then
- begin
- MessageBeep(0);
- MessageBox(HWindow, 'Enter Yes into dialog', 'Error!', mb_Ok);
- SendDlgItemMsg(id_Input, em_SetSel, 0, MAKELONG(32767, 0))
- end;
- CanClose := OkToClose
- end;
-
-
- { GinputApplication }
-
- {- Initialize GinputApplication object's window }
- procedure GinputApplication.InitMainWindow;
- begin
- MainWindow := New(PGinputWindow, Init(nil, 'Ginput'))
- end;
-
-
- { GinputWindow }
-
- {- Construct GinputWindow object }
- constructor GinputWindow.Init(AParent: PWindowsObject; ATitle: PChar);
- begin
- TWindow.Init(AParent, ATitle);
- Attr.Menu := LoadMenu(HInstance, PChar(id_Menu));
- Buffer[0] := Chr(0) { Empty buffer }
- end;
-
- {- Prompt for input into GinputWindow's Buffer field }
- procedure GinputWindow.GetInput(var Msg: TMessage);
- begin
- Application^.ExecDialog(New(PCustom,
- Init(@Self, 'Input Dialog', 'Please enter something: ',
- Buffer, Sizeof(Buffer))))
- end;
-
-
- var
-
- GinputApp: GinputApplication;
-
- begin
- GinputApp.Init('GinputApp');
- GinputApp.Run;
- GinputApp.Done
- end.
-
-
- {--------------------------------------------------------------
- Copyright (c) 1991 by Tom Swan. All rights reserved.
- Revision 1.00 Date: 3/12/1991
- ---------------------------------------------------------------}
-